// components/park/list.ts
// pages/mine/mine.ts
// import { ajax } from "../../utils/request";

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    point: {
      type: Object
    },
    listData: {
      type: Array
    },
    selectId: {
      type: Number
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 点击后高亮显示
    handleHighlight(e:WechatMiniprogram.BaseEvent) {
      console.log("高亮显示！");
      // this.setData({selectId: e.currentTarget.dataset.pid});
      this.triggerEvent("itemTap",e.currentTarget.dataset.pid)
    },
    // 预约
    handleBook(e:WechatMiniprogram.BaseEvent) {
      let pid = e.currentTarget.dataset.pid;
      let item = this.data.listData.find(v => v.pid == pid);
      wx.navigateTo({
        url: "/pages/book/index/book-index",
        success(res:WechatMiniprogram.NavigateToSuccessCallbackResult) {
          res.eventChannel.emit("sendData",item)
        }
      })
    },
    handleRoute(e: any) {
      // name,latitude,longitude
      const obj = {...e.currentTarget.dataset};
      // console.log("obj = ",obj);

      // let plugin = requirePlugin('routePlan');
      // let key = 'BLSBZ-B25KF-76DJX-JM7D2-Q7JNH-VRBOE';  //使用在腾讯位置服务申请的key
      // let referer = '我的停车学习';   //调用插件的app的名称
      // let endPoint = JSON.stringify(obj);
      // wx.navigateTo({
      //   url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
      // });
      wx.openLocation({
        latitude: obj.latitude,
        name: obj.name,
        longitude: obj.longitude,
      })
    }
  },
  observers: {
    "point": function (val) {
      if (!val) {
        return;
      }
      // ajax("/location/distanceTopark",val).then(res => {
      //   if (res.data.code === 0) {
      //     this.setData({listData:res.data.data});
      //   }
      // })
    }
  }
})
